package bancoperu.rest;


import java.util.Collection;
import java.util.Date;

import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import bancoperu.dao.AccountDAO;
import bancoperu.dao.CustomerDAO;
import bancoperu.dao.TransactionDAO;
import bancoperu.model.Account;
import bancoperu.model.Customer;
import bancoperu.model.Transaction;

@Path("/statement")
public class StatementRest {
	

	
	@GET
	@Path("/full")
	@Produces(MediaType.TEXT_PLAIN)
	public String getAllCustomers(@QueryParam("CustomerID") String CustomerID, 
			@QueryParam("chkAccount") int chkAccount , 
			@QueryParam("chkTransaction") String chkTransaction) {		
		
		JSONArray array = new JSONArray();
		
		try {
			
			
			AccountDAO aDao = new AccountDAO();
			String accountId = aDao.GetAccountID(CustomerID, chkAccount);
			
			
			TransactionDAO dao = new TransactionDAO();
			Collection<Transaction> transactions = dao.getFullTransactions(accountId, CustomerID);		
			
			System.out.println("Transaction about to be Added!!!!!!!!!" + transactions.size());
			array.addAll(transactions);
			System.out.println(array.toString());
			
		} catch (Exception e) {	
			//e.printStackTrace();
			System.out.println(e.getMessage());
		}
		return array.toString();
	}
	
	
}
